using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media.Imaging;
using System.Windows.Resources;

namespace QuizzMe.ValueConverters
{
    /// <summary>
    /// Abstract wrapper of ValueConverter to handle String to Icon conversion
    /// </summary>
    public abstract class ImageConverter : IValueConverter
    {
        public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);

        public static BitmapImage ImageFromResource(string file)
        {
            StreamResourceInfo sr = Application.GetResourceStream(new Uri(string.Format("QuizzMe;component/Resources/{0}.png", file), UriKind.Relative));
            BitmapImage img = new BitmapImage();
            img.SetSource(sr.Stream);

            return img;
        }

        public abstract object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture);
    }
}